let db = require('../db.js');

//设备数据拉取

exports.equipmentList = async  function(start,length,name) {
 
    start = parseInt(start);
    length = parseInt(length);
     let sql=`
     SELECT SQL_CALC_FOUND_ROWS *,
     DATE_FORMAT(createdAt,'%Y-%m-%d %H:%i') AS createdAt
     FROM   equipment 
     `
     sql+=` limit :start,:length ;`
     sql += `   SELECT FOUND_ROWS() sum;`
     sql = sql.replace('AND', 'WHERE');
 
     let data = await db.query(sql,{start,length,name});
     return data[0];
 }
 

 //删除部门

exports.delEquipment = async function(id){
    let sql=`
    delete  from equipment   where id =:id
    `
    let data = await db.query(sql,{id});
     return data[0];
}